<?php

// sicherheit
require_once ('security.php');

if (isset($_GET['loesche'])){
	
    $masterDoc = new DomDocument('1.0', 'utf-8');
    $filename = '../content/languageschools/master.xml';
	if(file_exists($filename)) {
		$masterDoc->Load($filename);
	}else die ("Konnte XML Datei nicht öffnen");
	$master = $masterDoc->documentElement;
	$schoolSet = $masterDoc->getElementsByTagName('school');
	$deletedschool;
	foreach( $schoolSet as $school ){
		$schoolId = $school->getElementsByTagName( 'id' )->item(0)->nodeValue;
		if ($schoolId==$_GET['loesche']){
			$deletedschool = $school;
		}
	}
	$master->removeChild($deletedschool);
	$masterDoc->save("../content/languageschools/master.xml");
	
	header ('location: menu.php');
}

// erstelle schulinstanz
require_once ('../scripts/php/languageschool.php');
$school = new School($_GET['schoolid']);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Schule löschen</title>
</head>
<link href="style.css" rel="stylesheet" type="text/css">
<div class="menubox">
<h2>Wollen Sie diese Schule wirklich löschen?</h2>
<?php echo "Id: ".$school->getId()." in ".$school->getCity()."/ ".$school->getCountry(); ?>
<p><a href="menu.php"> Nein -> zurück zum Menü</a></p>
<p><a href="loescheschule.php?loesche=<?php echo $school->getId(); ?>"> Ja -> Weg damit...</a></p>
</div></html>